/**************************************************************************
*  FileName     : flash.h
*  Author       : liupan
*  Version      : 1.0
*  Create Date  : 2020/04/22
*  Description  : Wifi module driver.
*  Other:
*  Funciton List:
*  History:
*  {
*     1:
*      Date:
*	   Author:
*	   Modification:
*     2:
*      Date:
*	   Author:
*	   Modification:
*
*  }
*
*
**************************************************************************/

#ifndef __FLASH_H_
#define __FLASH_H_
#include "stm32f4xx.h"
#include "flash_define.h"
typedef enum
{                      
    E_FLASH_SECTOR_5    = 0x05U,  
	  E_FLASH_SECTOR_6    = 0x06U,                       
    E_FLASH_SECTOR_7    = 0x07U, 
	  E_FLASH_SECTOR_8    = 0x08U,                       
    E_FLASH_SECTOR_9    = 0x09U,  
	  E_FLASH_SECTOR_10    = 0x0AU,                       
    E_FLASH_SECTOR_11    = 0x0BU,  	
}TE_FLASH_SECTOR;


/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
#define FLASH_BASE_ADDR      (uint32_t)(FLASH_BASE)
#define FLASH_END_ADDR       (uint32_t)(FLASH_END)
#define SECTOR_SIZE          ((uint32_t)0x0020000)

/* Base address of the Flash sectors Bank 1 */
#define ADDR_FLASH_SECTOR_0_BANK1     ((uint32_t)0x08000000) /* Base @ of Sector 0, 16 Kbytes */
#define ADDR_FLASH_SECTOR_1_BANK1     ((uint32_t)0x08004000) /* Base @ of Sector 1, 16 Kbytes */
#define ADDR_FLASH_SECTOR_2_BANK1     ((uint32_t)0x08008000) /* Base @ of Sector 2, 16 Kbytes */
#define ADDR_FLASH_SECTOR_3_BANK1     ((uint32_t)0x0800C000) /* Base @ of Sector 3, 16 Kbytes */
#define ADDR_FLASH_SECTOR_4_BANK1     ((uint32_t)0x08010000) /* Base @ of Sector 4, 64 Kbytes */
#define ADDR_FLASH_SECTOR_5_BANK1     ((uint32_t)0x08020000) /* Base @ of Sector 5, 128 Kbytes */
#define ADDR_FLASH_SECTOR_6_BANK1     ((uint32_t)0x08040000) /* Base @ of Sector 6, 128 Kbytes */
#define ADDR_FLASH_SECTOR_7_BANK1     ((uint32_t)0x08060000) /* Base @ of Sector 7, 128 Kbytes */
#define ADDR_FLASH_SECTOR_8_BANK1     ((uint32_t)0x08080000) /* Base @ of Sector 8, 128 Kbytes */
#define ADDR_FLASH_SECTOR_9_BANK1     ((uint32_t)0x080A0000) /* Base @ of Sector 9, 128 Kbytes */
#define ADDR_FLASH_SECTOR_10_BANK1    ((uint32_t)0x080C0000) /* Base @ of Sector 10, 128 Kbytes */
#define ADDR_FLASH_SECTOR_11_BANK1    ((uint32_t)0x080E0000) /* Base @ of Sector 11, 128 Kbytes */

#define FLASH_APP_ADDR ADDR_FLASH_SECTOR_5_BANK1

#define FLASH_PARA_ADDR ADDR_FLASH_SECTOR_11_BANK1 

TE_FLASH_STATUS FlashWrite(uint32_t startAddr, uint8_t *data,uint32_t len);

TE_FLASH_STATUS FlashRead(uint32_t startAddr, uint8_t *data,uint32_t len);

TE_FLASH_STATUS FlashErase(TE_FLASH_SECTOR sector,uint8_t sector_num);


void FlashTest(void);



#endif
